package com.kaiyidiannao.model.req.model;

import android.util.Log;
import com.kaiyidiannao.data.DataCenter;
import com.kaiyidiannao.https.HttpUtils;
import com.kaiyidiannao.model.Result;
import com.kaiyidiannao.model.req.base.BaseCommand;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * 详情页面的我的收藏 (添加，删除)
 * @author david
 */
public class PostAddFavorites extends BaseCommand {

    private String userid; //用户id
    private String action = ""; //添加数据
    private String TAG = "PostAddFavorites";
    private String itemid;
    private String title;
    private int catid;

    private String info = "1";

    public PostAddFavorites(int catid, String userid, String action, String itemid, String title) {
        this.catid = catid;
        this.userid = userid;
        this.action = action;
        this.itemid = itemid;
        this.title = title;
    }

    @Override
    public String getRequestUrl() {
        return DataCenter.POST_FAVORITES_ADDRESS;
    }

    @Override
    public HashMap<String, String> getRequestParamters() {
        HashMap<String, String> paramters = new HashMap<String, String>();
        paramters.put("catid", catid + "");
        paramters.put("userid", userid + "");
        paramters.put("action", action + "");
        paramters.put("itemid", itemid + "");
        paramters.put("title", title);
        paramters.put("info", info);
        return paramters;
    }

    @Override
    public Result go(String url, HashMap<String, String> paramters) { // 联网时后台执行
        // 根据请求参数返回请求数据
        return HttpUtils.postByHttpClient(url, paramters);
    }

    @Override
    public void yes(Result result) { //后台执行完毕后执行
        super.yes(result);
        Log.d(DataCenter.LOG_INFO, "PostAddFavorites.yes()");
        DataCenter.getInstance().callBacks(DataCenter.flag.GetAddMESSAGEINFO_SUCCESS);
    }

    @Override
    public void no(Result result) {
        super.no(result);
        DataCenter.getInstance().callBacks(DataCenter.flag.GetAddMESSAGEINFO_FAILED);
    }
}
